<?php
include_once("../includes/config.php");
include_once("../includes/mod_function.inc.php");

global $foxydb;

  $doc = new DOMDocument();
  $doc->load( '../data/website_category_google.xml' );
  
  //Note:- categories have already been imported to use this script

  $cats = $doc->getElementsByTagName( "Category" );
$foxydb->open();
  foreach( $cats as $cat )
  {
		$catsid = $cat->getAttribute("categoryId");
		foreach($cat->childNodes as $k => $child){
			if ($child->nodeType == 1 && $child->nodeName == "Site") { 	
				$site = $child;
				$uri = $site->getAttribute("uri");
				$name = $site->getAttribute("name");

				$s = $foxydb->findSiteByUri($uri);
				if(!$s){
					$foxydb->registerSite($uri,$name,"","","",$catsid,0,"");
				}

				$s = $foxydb->findSiteByUri($uri);
				//print_r($s);
				echo $s['sid']." -- ".$catsid."<br>";
				if($s) $foxydb->addSiteToCategory($s['sid'],$catsid,$k);
			}
		}		  
  }
$foxydb->close();

?>